package com.alibaba.nacos;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.actuate.autoconfigure.security.servlet.ManagementWebSecurityAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.http.HttpServletResponse;

@SpringBootApplication(scanBasePackages = "com.alibaba.nacos",
        exclude = {SecurityAutoConfiguration.class, ManagementWebSecurityAutoConfiguration.class})
@ServletComponentScan
@EnableScheduling
public class NacosApplication {

    private static String standalone = "true";

    private static String enable = "false";

    public static void main(String[] args) {
        System.setProperty("nacos.standalone", standalone);
        System.setProperty("nacos.core.auth.enable", enable);
        System.setProperty("server.tomcat.basedir", "logs");
        SpringApplication.run(NacosApplication.class, args);
    }

    /**
     * 默认跳转首页
     *
     * @param model
     * @return
     */
    @GetMapping("/")
    public String index(Model model, HttpServletResponse response) {
        // 视图重定向 - 跳转
        return "/nacos";
    }
}
